package logic

import (
	"context"

	"user/internal/svc"
	"user/pb/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type CheckPasswordLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCheckPasswordLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CheckPasswordLogic {
	return &CheckPasswordLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// CheckPassword 校验密码
func (l *CheckPasswordLogic) CheckPassword(in *user.CheckPasswordRequest) (*user.Empty, error) {
	err := l.svcCtx.UserExtendModel.CheckPassword(l.ctx, in.Id, in.Password)
	if err != nil {
		return nil, err
	}
	return &user.Empty{}, nil
}
